package dice.sinanya.db.des;

import dice.sinanya.db.tools.DbUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author SitaNya
 * 日期: 2019-06-15
 * 电子邮箱: sitanya@qq.com
 * 维护群(QQ): 162279609
 * 有任何问题欢迎咨询
 * 类说明: 录入KP主群类
 */
public class InsertDes {
    private static final Logger log = LogManager.getLogger(InsertDes.class.getName());

    public void insertDes(long qqId, String key, String value) {
        try (Connection conn = DbUtil.getConnection()) {
            //language=MySQL
            String sql = "replace test.des(qqId,`key`,`value`) value(?,?,?)";
            try (PreparedStatement ps = conn.prepareStatement(sql)) {
                ps.setLong(1, qqId);
                ps.setString(2, key);
                ps.setString(3, value);
                ps.executeUpdate();
            }
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
        }
    }
}